
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Tmain: a facility for testing main part &#8212; Universal Ctags 0.3.0 documentation</title>
    <link rel="stylesheet" href="_static/classic.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '0.3.0',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Tinst installation test" href="tinst.html" />
    <link rel="prev" title="Chop and slap testing" href="chop.html" /> 
  </head>
  <body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="tinst.html" title="Tinst installation test"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="chop.html" title="Chop and slap testing"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">Universal Ctags 0.3.0 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="testing.html" accesskey="U">Testing ctags</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="tmain-a-facility-for-testing-main-part">
<h1><em>Tmain</em>: a facility for testing main part<a class="headerlink" href="#tmain-a-facility-for-testing-main-part" title="Permalink to this headline">¶</a></h1>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Maintainer:</th><td class="field-body">Masatake YAMATO &lt;<a class="reference external" href="mailto:yamato&#37;&#52;&#48;redhat&#46;com">yamato<span>&#64;</span>redhat<span>&#46;</span>com</a>&gt;</td>
</tr>
</tbody>
</table>
<hr class="docutils" />
<p><em>Tmain</em> is introduced to test the area where <em>Units</em>
does not cover well.</p>
<p><em>Units</em> works fine for testing parsers. However, it
assumes something input is given to ctags command,
and a <cite>tags</cite> file is generated from ctags command.</p>
<p>Other aspects cannot be tested. Such areas are files
and directories layout after installation, standard
error output, exit status, etc.</p>
<p>You can run test cases with following command line:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ make tmain
</pre></div>
</div>
<p><em>Tmain</em> is still under development so I will not write
the details here.</p>
<p>To write a test case, see files under <cite>Tmain/tmain-example.d</cite>.
In the example, <em>Tmain</em> does:</p>
<ol class="arabic simple">
<li>runs new subshell and change the working directory to <cite>Tmain/tmain-example.d</cite>,</li>
<li>runs <cite>run.sh</cite> with <cite>bash</cite>,</li>
<li>captures stdout, stderr and exit status, and</li>
<li>compares them with <cite>stdout-expected.txt</cite>, <cite>stderr-expected.txt</cite>,
and <cite>exit-expected.txt</cite>.</li>
<li>compares it with <cite>tags-expected.txt</cite> if run.sh generates <cite>tags</cite> file.</li>
</ol>
<p><cite>run.sh</cite> is run with following 4 arguments:</p>
<ol class="arabic simple">
<li>the path for the target ctags</li>
<li>the path for <cite>builddir</cite> directory</li>
<li>the path for the target readtags</li>
</ol>
<p>The path for readtags is not reliable; readtags command is not
available if –disable-readcmd was given in configure time.  A case,
testing the behavior of readtags, must verify the command existence
with <cite>test -x $4</cite> before going into the main part of the test.</p>
<p>When comparing <cite>tags</cite> file with <cite>tags-expected.txt</cite>, you
must specify the path of <cite>tags</cite> explicitly with -o option
in ctags command line like:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>CTAGS=$1
BUILDDIR=$3
${CTAGS} ... -o $BUILDDIR/tags ...
</pre></div>
</div>
<p>This makes it possible to keep the original source directory clean.</p>
<p>See also <cite>tmain_run</cite> and <cite>tmain_compare</cite> functions in <cite>misc/units</cite>.</p>
<p>If run.sh exits with code 77, the test case is skipped.
The output to stdout is captured and printed as the reason
of skipping.</p>
<div class="section" id="todo">
<h2>TODO<a class="headerlink" href="#todo" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li>Run under valgrind</li>
</ul>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#"><em>Tmain</em>: a facility for testing main part</a><ul>
<li><a class="reference internal" href="#todo">TODO</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="chop.html"
                        title="previous chapter"><em>Chop</em> and <em>slap</em> testing</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="tinst.html"
                        title="next chapter"><em>Tinst</em> installation test</a></p>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <div><input type="text" name="q" /></div>
      <div><input type="submit" value="Go" /></div>
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="tinst.html" title="Tinst installation test"
             >next</a> |</li>
        <li class="right" >
          <a href="chop.html" title="Chop and slap testing"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">Universal Ctags 0.3.0 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="testing.html" >Testing ctags</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2015, Universal Ctags Team.
      Last updated on 19 Dec 2017.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.4.
    </div>
  </body>
</html>